import BaseUtil from '@/BaseUtil';
import TimerDialogUtil from '@/TimerDialogUtil';
import UnitStateUtil from '@/UnitStateUtil';
import UnitUtil from "@/UnitUtil";

export default class HeroReviveOnDeath {


    constructor() {
        //任意单位事件 - 死亡
        se.onUnitDeath(e => {
            //触发单位所属玩家id
            if (e.trigUnitOwnerId < 4 && e.isHeroUnitTrig) {

                let hero = e.trigUnit;
                BaseUtil.runLater(0.01, () => {
                    if (!UnitAlive(hero) && !IsUnitType(hero, UNIT_TYPE_STRUCTURE)) {//如果已经重生了 则不需要走基础复活系统
                        TimerDialogUtil.show(GetUnitName(hero), 3)
                        BaseUtil.runLater(3, () => {
                            ReviveHero(hero, GetUnitX(hero), GetUnitY(hero), true);
                            UnitUtil.transfer(hero,-9893,6852)
                            SetUnitLifePercentBJ(hero, 100)
                            SetUnitManaPercentBJ(hero, 100)
                            BJDebugMsg(tostring(GetUnitName(hero)) + "复活了!")
                        });
                    }

                });


            }
        })


    }


}